import { ApiProperty } from '@nestjs/swagger'
import {
  IsNotEmpty,
  MinLength,
  MaxLength,
  IsPhoneNumber,
  IsString,
  Length,
  IsNumber,
  IsOptional,
  IsEnum,
  IsIdentityCard,
  IsEmail
} from 'class-validator'
import {
  EducationLevelEnum,
  EngageFormEnum,
  NationEnum,
  PoliticalAffiliationEnum,
  SexEnum,
  WedlockEnum
} from 'src/types/staff'
export class CreateStaffDto {
  @ApiProperty({ example: '13708171317', description: '手机号' })
  @IsNotEmpty({ message: '手机号不能为空' })
  @IsString({ message: '手机号必须为字符串类型' })
  @IsPhoneNumber('CN', { message: '手机号格式不正确' })
  phone: string
  @ApiProperty({
    example: '123456',
    description: '密码',
    minLength: 6,
    maxLength: 20
  })
  @IsString({ message: '密码必须为字符串类型' })
  @IsOptional()
  @MinLength(6, {
    message: '密码长度不能小于6位'
  })
  @MaxLength(20, {
    message: '密码长度不能超过20位'
  })
  password?: string = '123456'
  @ApiProperty({ example: '张三', description: '姓名' })
  @IsNotEmpty({ message: '姓名不能为空' })
  @IsString({ message: '姓名必须为字符串类型' })
  @Length(2, 5, { message: '姓名长度必须在2-5位之间' })
  name: string

  @ApiProperty({
    example: 1,
    description: '性别',
    enum: SexEnum,
    required: false,
    default: SexEnum['男']
  })
  @IsOptional()
  @IsNumber({}, { message: '性别必须为数字类型' })
  @IsEnum(SexEnum, { message: '性别不合法' })
  sex?: number

  @ApiProperty({
    example: '1990-01-01',
    description: '出生日期',
    required: false
  })
  @IsOptional()
  @IsString({ message: '出生日期必须为字符串类型' })
  @Length(10, 10, { message: '出生日期格式不正确' })
  birthday?: string

  @ApiProperty({ example: '513902200005235855', description: '身份证号' })
  @IsOptional()
  @IsIdentityCard('zh-CN', { message: '身份证号格式不正确' })
  @IsString({ message: '身份证号必须为字符串类型' })
  @Length(18, 18, { message: '身份证号长度必须为18位' })
  idCard?: string

  @ApiProperty({
    example: 1,
    description: '婚姻状况',
    enum: WedlockEnum,
    required: false,
    default: WedlockEnum['未婚']
  })
  @IsOptional()
  @IsNumber({}, { message: '婚姻状况必须为数字类型' })
  @IsEnum(WedlockEnum, { message: '婚姻状况不合法' })
  wedlock?: number

  @ApiProperty({
    example: '1',
    description: '民族',
    enum: NationEnum,
    default: NationEnum['汉族'],
    required: false
  })
  @IsOptional()
  @IsEnum(NationEnum, { message: '民族不合法' })
  @IsNumber({}, { message: '民族必须为数字类型' })
  nation?: number

  @ApiProperty({ example: '四川', description: '籍贯', required: false })
  @IsOptional()
  @IsString({ message: '籍贯必须为字符串类型' })
  @MaxLength(20, { message: '籍贯长度不能超过20位' })
  nativePlace?: string

  @ApiProperty({
    example: '12',
    description: '政治面貌',
    enum: PoliticalAffiliationEnum,
    default: PoliticalAffiliationEnum['群众'],
    required: false
  })
  @IsOptional()
  @IsEnum(PoliticalAffiliationEnum, { message: '政治面貌不合法' })
  @IsNumber({}, { message: '政治面貌必须为数字类型' })
  politicalAffiliation?: number

  @ApiProperty({
    example: '872337784@qq.com',
    description: '邮箱',
    required: false
  })
  @IsOptional()
  @IsEmail({}, { message: '邮箱格式不正确' })
  @IsString({ message: '邮箱必须为字符串类型' })
  @MaxLength(50, { message: '邮箱长度不能超过50位' })
  email?: string

  @ApiProperty({
    example: '四川省成都市',
    description: '地址',
    required: false
  })
  @IsOptional()
  @IsString({ message: '地址必须为字符串类型' })
  @MaxLength(50, { message: '地址长度不能超过50位' })
  address?: string

  @ApiProperty({ example: '1', description: '部门id' })
  @IsNotEmpty({ message: '部门id不能为空' })
  @IsNumber({}, { message: '部门id必须为数字类型' })
  departmentId: number

  @ApiProperty({ example: '1', description: '职位id' })
  @IsNotEmpty({ message: '职位id不能为空' })
  @IsNumber({}, { message: '职位id必须为数字类型' })
  jobId: number

  @ApiProperty({ example: 10000, description: '基本工资' })
  @IsNumber({}, { message: '基本工资必须为数字类型' })
  @IsOptional()
  basisSalary?: number

  @ApiProperty({
    example: '1',
    enum: EngageFormEnum,
    default: EngageFormEnum['合同'],
    description: '合同形式'
  })
  @IsNotEmpty({ message: '合同形式不能为空' })
  @IsEnum(EngageFormEnum, { message: '合同形式不合法' })
  @IsNumber({}, { message: '合同形式必须为数字类型' })
  engageForm: number

  @ApiProperty({
    example: '1',
    description: '最高学历',
    enum: EducationLevelEnum,
    default: EducationLevelEnum['其他']
  })
  @IsOptional()
  @IsEnum(EducationLevelEnum, { message: '最高学历不合法' })
  @IsNumber({}, { message: '最高学历必须为数字类型' })
  educationLevel?: number

  @ApiProperty({ example: '软件工程', description: '所属专业' })
  @IsOptional()
  @IsString({ message: '所属专业必须为字符串类型' })
  @MaxLength(10, { message: '所属专业长度不能超过10位' })
  specialty?: string

  @ApiProperty({ example: '四川轻化工大学', description: '毕业院校' })
  @IsOptional()
  @IsString({ message: '毕业院校必须为字符串类型' })
  @MaxLength(15, { message: '毕业院校长度不能超过15位' })
  school?: string

  @ApiProperty({ example: '2019-01-01', description: '入职日期' })
  @IsOptional()
  @IsString({ message: '入职日期必须为字符串类型' })
  @Length(10, 10, { message: '入职日期格式不正确' })
  inDate?: string

  @ApiProperty({ example: '1', description: '工作状态ID' })
  @IsOptional()
  @IsNumber({}, { message: '工作状态ID必须为数字类型' })
  workStateId?: number

  @ApiProperty({ example: '1', description: '合同期限' })
  @IsNotEmpty({ message: '合同期限不能为空' })
  @IsNumber({}, { message: '合同期限必须为数字类型' })
  contractDate: number

  @ApiProperty({
    example: '2019-01-01',
    description: '转正日期',
    required: false
  })
  @IsOptional()
  @IsString({ message: '转正日期必须为字符串类型' })
  @Length(10, 10, { message: '转正日期格式不正确' })
  formDate?: string

  @ApiProperty({
    example: '2019-01-01',
    description: '离职日期',
    required: false
  })
  @IsOptional()
  @IsString({ message: '离职日期必须为字符串类型' })
  @Length(10, 10, { message: '离职日期格式不正确' })
  leaveDate?: string

  @ApiProperty({ example: '2019-01-10', description: '合同起始日期' })
  @IsNotEmpty({ message: '合同起始日期不能为空' })
  @IsString({ message: '合同起始日期必须为字符串类型' })
  @Length(10, 10, { message: '合同起始日期格式不正确' })
  beginDate: string

  @ApiProperty({ example: '2020-01-10', description: '合同终止日期' })
  @IsOptional()
  @IsString({ message: '合同终止日期必须为字符串类型' })
  @Length(10, 10, { message: '合同终止日期格式不正确' })
  endDate?: string

  @ApiProperty({ example: '1', description: '工龄', required: false })
  @IsNumber({}, { message: '工龄必须为数字类型' })
  @IsOptional()
  workAge?: number

  @ApiProperty({ example: '123.png', description: '头像', required: false })
  @IsOptional()
  @IsString({ message: '头像必须为字符串类型' })
  @MaxLength(50, { message: '头像长度不能超过50位' })
  avatar?: string
}
